import { listVenue } from "@/api/showroom/venue";
import { compare } from "@/utils/index"

const venue = {
  state: {
    list:[],
    venuelist0:[]

  },

  mutations: {
    SET_LIST: (state, data) => {
      state.list = data
    },
    SETVENUELIST: (state, data) => {
      state.venuelist0 = data
    }
  },

  actions: {
      // 获取场馆列表
    GetVenueList({ commit, state }) {
      if (!state.list.length) {
        return new Promise((resolve, reject) => {
          listVenue().then(res => {
            const venueList = res.data;
            // venueList.sort(compare('id', true));

              commit('SET_LIST',venueList)
              console.log(venueList)

              let list0 = venueList.filter((item, index, arr) => {
                return item.venueType == 0;
              })
              console.log(list0)
              commit('SETVENUELIST',list0)

            resolve(res)
          }).catch(error => {
            reject(error)
          })
        })
      }

    },
  }
}

export default venue
